package com.cnplan.controller;

import com.cnplan.core.KUtil;
import com.cnplan.entity.ArcRoll;
import com.cnplan.entity.ArcRollImage;
import com.cnplan.service.ArcRollImageService;
import com.cnplan.service.ArcRollService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/arc_roll_image")
public class ArcRollImageController {

    @Autowired
    private ArcRollImageService arcRollImageService;
    @Autowired
    private  KUtil kUtil;
    @Autowired
    private ArcRollService arcRollService;
    @GetMapping("/findpage")
    public Object findPage(@RequestParam Map map){
        return arcRollImageService.findByArcRollImage(map);
    }

    @GetMapping("/list")
    public String archivesList(@RequestParam Map map, Model model){
        ArcRoll arcRoll=arcRollService.findById(map.get("ctId").toString());
        PageInfo pageInfo=arcRollImageService.findByArcRollImage(map);
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("arcRoll",arcRoll);
        return "archives/arcrollimage";
    }

    @GetMapping("/listAll")
    @ResponseBody
    public List<ArcRollImage> archivesListAll(@RequestParam("ctId") String ctId){
        List<ArcRollImage> arcRollImages= arcRollImageService.findAllRollImage(ctId);
        return arcRollImages;
    }

    @GetMapping("/imagePath")
    @ResponseBody
    public void imagePath(){
//        arcRollImageService.updateRollImageURl("21d2c4b6-4d92-41de-95a7-3ed8bc4fbb13","qwerwqetqw");
        kUtil.imagePath();
    }
}
